package com.huaxin.hxmoduleworkorder.common.validator;

import com.huaxin.hxmoduleworkorder.common.annotation.validation.ValidCustomerType;
import com.huaxin.hxmoduleworkorder.common.enums.CustomerType;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class CustomerTypeValidator implements ConstraintValidator<ValidCustomerType, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        // 允许 null 或空值通过（如果字段本身允许 null）
        if (value == null || value.trim().isEmpty()) {
            return true;
        }
        return CustomerType.isValid(value);
    }
}
